package edu.online.dal;

import edu.online.entity.LeaveLessonEntity;
import org.apache.ibatis.jdbc.SQL;

public class LeaveLessonEntitySqlProvider {

    public String insertSelective(LeaveLessonEntity record) {
        SQL sql = new SQL();
        sql.INSERT_INTO("leavelesson");
        
        if (record.getLeavelessonid() != null) {
            sql.VALUES("LeaveLessonID", "#{leavelessonid,jdbcType=CHAR}");
        }
        
        if (record.getLessonid() != null) {
            sql.VALUES("LessonID", "#{lessonid,jdbcType=CHAR}");
        }
        
        if (record.getStudentid() != null) {
            sql.VALUES("StudentId", "#{studentid,jdbcType=CHAR}");
        }
        
        if (record.getAdminuserid() != null) {
            sql.VALUES("AdminUserId", "#{adminuserid,jdbcType=CHAR}");
        }
        
        if (record.getRequesttime() != null) {
            sql.VALUES("RequestTime", "#{requesttime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getConfirmtime() != null) {
            sql.VALUES("ConfirmTime", "#{confirmtime,jdbcType=TIMESTAMP}");
        }
        
        return sql.toString();
    }

    public String updateByPrimaryKeySelective(LeaveLessonEntity record) {
        SQL sql = new SQL();
        sql.UPDATE("leavelesson");
        
        if (record.getLessonid() != null) {
            sql.SET("LessonID = #{lessonid,jdbcType=CHAR}");
        }
        
        if (record.getStudentid() != null) {
            sql.SET("StudentId = #{studentid,jdbcType=CHAR}");
        }
        
        if (record.getAdminuserid() != null) {
            sql.SET("AdminUserId = #{adminuserid,jdbcType=CHAR}");
        }
        
        if (record.getRequesttime() != null) {
            sql.SET("RequestTime = #{requesttime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getConfirmtime() != null) {
            sql.SET("ConfirmTime = #{confirmtime,jdbcType=TIMESTAMP}");
        }
        
        sql.WHERE("LeaveLessonID = #{leavelessonid,jdbcType=CHAR}");
        
        return sql.toString();
    }
}